package com.ssy.lingxi.platform.manage.repository;


import com.ssy.lingxi.platform.manage.entity.content.MemberInformation;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface MemberInformationRepository extends JpaRepository<MemberInformation, Long>, JpaSpecificationExecutor<MemberInformation> {

    Boolean existsBySortAndRecommendLabel(Integer sort, Integer recommendLabel);

    Boolean existsAllByFirstCategoryIdOrSecondCategoryIdOrThirdlyCategoryId(Long firstCategoryId, Long secondCategoryId, Long thirdlyCategoryId);

    List<MemberInformation> findAllByMemberIdAndMemberRoleIdAndRecommendLabelAndStatus(Long memberId, Long memberRoleId, Integer recommendLabel, Integer status, Sort sort);

    List<MemberInformation> findAllByColumnIdAndStatus(Long columnId, Integer status, Sort sort);

    List<MemberInformation> findAllByColumnIdInAndStatusAndThirdlyCategoryId(List<Long> columnIdList, Integer status, Long thirdlyCategoryId);

    List<MemberInformation> findAllByColumnIdInAndStatus(List<Long> columnIdList, Integer status);

    Page<MemberInformation> findAllByMemberIdAndMemberRoleIdAndStatus(Long memberId, Long memberRoleId, Integer status, Pageable pageable);

    Page<MemberInformation> findAllByStatusAndColumnId(Integer status, Long id, Pageable pageable);

    MemberInformation findByMemberIdAndMemberRoleIdAndSortAndRecommendLabel(Long memberId, Long memberRoleId, Integer sort, Integer recommendLabel);

    MemberInformation findByColumnIdAndRecommendLabel(Long columnId, Integer recommendLabel);

    List<MemberInformation> findAllByFirstCategoryIdOrSecondCategoryIdOrThirdlyCategoryId(Long firstCategoryId, Long secondCategoryId, Long thirdlyCategoryId);

    Boolean existsAllByColumnId(Long columnId);

    List<MemberInformation> findAllByMemberIdAndMemberRoleId(Long memberId, Long memberRoleId);
}
